<template>
  <div class="box">
    <div class="top">
      <div>
        <span class="title">实时游客统计</span>
        <span class="title-bg"></span>
      </div>
      <div class="right">
        可预约总量：
        <span class="num">12345</span>
      </div>
    </div>

    <div class="peopleNum">
      <span v-for="(item, index) in people" :key="index">{{ item }}</span>
    </div>

    <div class="chart" ref="chartRef">123</div>
  </div>
</template>

<script setup lang="ts" name="tourist">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
import 'echarts-liquidfill'

let chartRef = ref()
onMounted(() => {
  //获取echarts实例
  let chart = echarts.init(chartRef.value)
  //配置项
  let option = {
    title: {
      text: '水球图',
    },
    //系列：决定展示什么样的图形图标
    series: [
      {
        data: [0.4],
        type: 'liquidFill',
        radius: '60%',
      },
    ],
    // 布局组件
    grid: {
      top: 0,
      bottom: 0,
      left: 0,
      right: 0,
    },
  }
  //渲染图表
  chart.setOption(option)
})

const people = ref('21290人')
</script>

<style scoped lang="scss">
.box {
  background: url('../../images/dataScreen-main-lb.png') no-repeat;
  background-size: cover;
  margin-top: 20px;

  .top {
    margin-left: 20px;
    display: flex;
    justify-content: space-between;
    .title {
      color: white;
      font-size: 20px;
    }
    .title-bg {
      margin-top: 7px;
      display: block;
      background: url('../../images/dataScreen-title.png') no-repeat;
      background-size: cover;
      width: 68px;
      height: 7px;
    }
    .right {
      margin: 20px 18px 0 0;
      color: white;
      font-size: 14px;
      .num {
        font-size: 14px;
        color: #67c23a;
      }
    }
  }

  .peopleNum {
    margin-top: 40px;
    display: flex;
    padding: 10px;
    span {
      background: url('../../images/total.png') no-repeat;
      background-size: 100% 100%;
      flex: 1;
      height: 40px;
      text-align: center;
      line-height: 40px;
      color: #29fcff;
      font-weight: bold;
    }
  }

  .chart {
    width: 100%;
    height: 240px;
  }
}
</style>
